use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::body::Body;

#[derive(Debug)]
pub enum ApiError {
    NotFound,
    // BadRequest(String),
    Internal(String),
}

impl IntoResponse for ApiError {
    fn into_response(self) -> Response {
        match self {
            ApiError::NotFound => Response::builder()
                .status(StatusCode::NOT_FOUND)
                .body(Body::empty())
                .unwrap(),
            // ApiError::BadRequest(msg) => Response::builder()
            //     .status(StatusCode::BAD_REQUEST)
            //     .header("Content-Type", "text/plain; charset=utf-8")
            //     .body(Body::from(msg))
            //     .unwrap(),
            ApiError::Internal(msg) => Response::builder()
                .status(StatusCode::INTERNAL_SERVER_ERROR)
                .header("Content-Type", "text/plain; charset=utf-8")
                .body(Body::from(msg))
                .unwrap(),
        }
    }
}